cmake_minimum_required(VERSION 3.1)

project(jvrc1_mj_description VERSION 1.0.0)

if(NOT TARGET mc_mujoco)
  find_package(mc_mujoco REQUIRED)
endif()

option(SRC_MODE "Use files in the repository instead of installed files" OFF)

set(JVRC1_XML_MODEL_PATH "xml/jvrc1.xml")
set(JVRC1_PDGAINS_PATH "pdgains/PDgains_sim.dat")

if(SRC_MODE)
  set(JVRC1_XML_MODEL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${JVRC1_XML_MODEL_PATH}")
  set(JVRC1_PDGAINS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${JVRC1_PDGAINS_PATH}")
else()
  set(JVRC1_XML_MODEL_PATH "${MC_MUJOCO_SHARE_DESTINATION}/JVRC1/${JVRC1_XML_MODEL_PATH}")
  set(JVRC1_PDGAINS_PATH "${MC_MUJOCO_SHARE_DESTINATION}/JVRC1/${JVRC1_PDGAINS_PATH}")
endif()

configure_file(mc_mujoco/jvrc1.in.yaml "${CMAKE_CURRENT_BINARY_DIR}/mc_mujoco/jvrc1.yaml")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/mc_mujoco/jvrc1.yaml" DESTINATION "${MC_MUJOCO_SHARE_DESTINATION}")

install(DIRECTORY meshes DESTINATION "${MC_MUJOCO_SHARE_DESTINATION}/JVRC1" FILES_MATCHING PATTERN "*.stl")
install(DIRECTORY pdgains DESTINATION "${MC_MUJOCO_SHARE_DESTINATION}/JVRC1" FILES_MATCHING PATTERN "*.dat")
install(DIRECTORY xml DESTINATION "${MC_MUJOCO_SHARE_DESTINATION}/JVRC1" FILES_MATCHING PATTERN "*.xml")
